var app = getApp()
var config = require('../../utils/config')

var status = true;

// pages/detail/detail.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    animationData: "",
    status: status,
    target_user_type: "",
    target_user_error: false,
    target_user_hint: "",
    target_user_info: {},
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    wx.setNavigationBarTitle({ title: '联系信息' })

    var title = "测试联系信息"
    var icon = "loading"
    var duration = 100000
    app.showToast(options,title, icon, duration)

    console.log(options)
    console.log(this.data.status)
    if(options.target_user_error=="true"){
      this.setData({
        target_user_error: options.target_user_error,
        target_user_hint: options.target_user_hint,
      })
    }else{
      this.setData({
        target_user_error: options.target_user_error,
        target_user_type: options.target_user_type,
        target_user_info: JSON.parse(options.target_user_info),
      })
    }
    console.log(this.data.target_user_error)
    console.log(this.data.target_user_hint)
    console.log(this.data.target_user_type)
    console.log(this.data.target_user_info)
    console.log(this.data.target_user_info.name)
  },
  goBack :function(){
    wx.navigateBack()
  },
  callMe: function (e) {
    console.log("准备拨打电话")
    let that = this
    console.log(that.data.target_user_info.mobile)
    wx.makePhoneCall({
      phoneNumber: that.data.target_user_info.mobile,
      success: function () {
        console.log("拨打电话成功！")
      },
      fail: function () {
        console.log("拨打电话失败！")
      }
    })
  }
})